<template>
  <div class="lazy-img" :style="{'width': width, 'height': height}">
    <div class="lazy-img-default">
      <img src="@/assets/images/bg_default.png" alt="">
    </div>
    <div class="lazy-img-wrap">
      <img :src="imgSrc" alt="">
    </div>
  </div>
</template>

<script>
export default {
  props: {
    width: {
      type: String,
      default: '100%'
    },
    height: {
      type: String,
      default: '56vw'
    },
    imgSrc: {
      type: String,
      default: ''
    }
  }
}
</script>

<style lang="scss" scoped>
.lazy-img {
  position: relative;
  width: 100%;
  height: 56vw;
  background-color:#f9f9f9;
  .lazy-img-default {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    img {
      width: .7rem;
    }
  }
  .lazy-img-wrap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    overflow: hidden;
    img {
      width: 100%;
      position: absolute;
      top: 50%;
      transform:translateY(-50%);
      left: 0;
    }
  }
}
</style>
